This repository contains the code to generate the DOKK graph using the
[data](https://notabug.org/DOKK/data) repository.

# Requirements

Tools used for creating the graph:

- java
- jena

    $ wget <jena tar from jena.apache.org>
    $ tar xzf ...
    $ mv jena-directory /usr/local/bin
    
    Append PATH="$HOME/jena/bin:$PATH" to your shell:
    $ vim ~/.profile
- jq
- rapper
- wget

## SPARQL endpoint

These are the instructions to setup your own Fuseki server if you want to have
a local copy of the DOKK database. **You are not required to follow these
steps unless you want your own local copy of the DOKK database**.

### Install Fuseki

Follow the [instructions from the official website](https://jena.apache.org/documentation/fuseki2/).
to install Fuseki, either as a service or a standalone server.
Also read [Fuseki File System Layout](https://jena.apache.org/documentation/fuseki2/fuseki-layout.html).

### Compile and install hdt-java libraries

        $ git clone https://github.com/rdfhdt/hdt-java.git
        
        Compile hdt-java
        --file: Specify a POM file as if we were executing Maven from that directory.
        $ mvn --file hdt-java/pom.xml clean install package
        
        Delete sources and only keep hdt-java .jar files
        $ cp hdt-java/hdt-api/target/hdt-api-*-SNAPSHOT.jar "${FUSEKI_HOME}/hdt-api.jar"
        $ cp hdt-java/hdt-java-core/target/hdt-java-core-*-SNAPSHOT.jar "${FUSEKI_HOME}/hdt-java-core.jar"
        $ cp hdt-java/hdt-jena/target/hdt-jena-*-SNAPSHOT.jar "${FUSEKI_HOME}/hdt-jena.jar"
        
        $ rm -rf hdt-java/

### Customize Fuseki configuration

1. Copy `fuseki/config.ttl` and `fuseki/log4j.properties` into
   your `$FUSEKI_BASE` folder
2. Edit the startup script `${FUSEKI_HOME}/fuseki-server` like this:
    
    - Adjust `JVM_ARGS=${JVM_ARGS:--Xmx1G}` to increase the JVM memory. This is
      required to accomodate HDT indices. If the memory is too low, you'll get
      an error when starting the server
    - Replace `exec $JAVA $JVM_ARGS -jar "$JAR" "$@"` with this
      ```
      Path to HDT jars to add to the class path.
      $ export FUSEKI_CLASSES="${FUSEKI_HOME}hdt-api.jar:${FUSEKI_HOME}hdt-java-core.jar:${FUSEKI_HOME}hdt-jena.jar"
      $ exec $JAVA $JVM_ARGS -classpath "$JAR:$FUSEKI_CLASSES" org.apache.jena.fuseki.cmd.FusekiCmd "$@"`
      ```

### Run server

Create the `fuseki` user and group:

        $ sudo groupadd fuseki
        $ sudo useradd -g fuseki fuseki

**As a standalone server**

From `$FUSEKI_HOME` run `./fuseki-server`. Make sure you have
`$FUSEKI_HOME` and `$FUSEKI_BASE` defined in your environment.

**As a service (systemd)**

Follow instructions in `fuseki.service` file in the Fuseki repository.
The server should be available at `http://localhost:3030`.

### Add data (graphs) to the database

DOKK uses [HDT files](http://www.rdfhdt.org), so you can add data to the
database simply by copying HDT files into `${FUSEKI_BASE}/databases/hdt/<graph-name>/`.
When you've copied all your HDT files, run `./write-configuration.sh`
to update the Fuseki configuration such that it will load the new graph
at startup.


# Contact

https://peers.community

contact@peers.community

#peers on freenode
